Demo of IPython Notebook

David Pine


In [1]:
2+3


Out[1]:
5

In [2]:
sin(pi/6.)


Out[2]:
0.49999999999999994

In [3]:
plot([1,2,3,2,3,4,3,4,5])


Out[3]:
[<matplotlib.lines.Line2D at 0x8e1fed0>]

In [4]:
# Calculates time, gallons of gas used, and cost of gasoline for
# a trip

distance = float(raw_input("Input distance of trip in miles: "))
mpg = 30.               # car mileage
speed = 60.             # average speed
costPerGallon = 4.10    # price of gas

time = distance/speed
gallons = distance/mpg
cost = gallons*costPerGallon

print("\nDuration of trip = {0:0.1f} hours".format(time))
print("Gasoline used = {0:0.1f} gallons (@ {1:0.0f} mpg)"
	  .format(gallons, mpg))
print("Cost of gasoline = ${0:0.2f} (@ ${1:0.2f}/gallon)"
	  .format(cost, costPerGallon))


Input distance of trip in miles: 450

Duration of trip = 7.5 hours
Gasoline used = 15.0 gallons (@ 30 mpg)
Cost of gasoline = $61.50 (@ $4.10/gallon)

The total distance $x$ traveled during a trip can be obtained by integrating the velocity $v(t)$ over the duration $T$ of the trip: \begin{align} x = \int_0^T v(t)\, dt \end{align}


In [5]:
!cat LiamSelinaData.txt


Date: 2013-09-16
Data taken by Liam and Selena
frequency (Hz) amplitude (mm)  amp error (mm)
    0.7500        13.52         0.32
    1.7885        12.11         0.92
    2.8269        14.27         0.73
    3.8654        16.60         2.06
    4.9038        22.91         1.75
    5.9423        35.28         0.91
    6.9808        60.99         0.99
    8.0192        33.38         0.36
    9.0577        17.78         2.32
   10.0962        10.99         0.21
   11.1346         7.47         0.48
   12.1731         6.72         0.51
   13.2115         4.40         0.58
   14.2500         4.07         0.63

In [ ]: